package designModel.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * 老师,实现被观察者
 */
public class Teacher implements Observable {
    //老师班级里的学生
    private List<Observer> myStudents = new ArrayList();

    @Override
    public void register(Observer observer) {
        myStudents.add(observer);
    }

    @Override
    public void remove(Observer observer) {
        myStudents.remove(observer);
    }

    @Override
    public void notify(String msg) {
        for (Observer observer : myStudents) {
            observer.update(msg);
        }
    }
}
